package wowraidmanager.shared.model.auction;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

import org.slim3.datastore.Attribute;
import org.slim3.datastore.Model;

import wowraidmanager.shared.model.auction.json.Auction;

import com.google.appengine.api.datastore.Key;

@Model(schemaVersion = 1)
public class AuctionList implements Serializable {

    private static final long serialVersionUID = 1L;

    @Attribute(primaryKey = true)
    private Key key;

    @Attribute(version = true)
    private Long version;

    private String itemId;

    private String realm;

    private String region;

    private Date date;

    @Attribute(lob = true)
    private ArrayList<Auction> auctionData;

    /**
     * Returns the key.
     *
     * @return the key
     */
    public Key getKey() {
        return key;
    }

    /**
     * Sets the key.
     *
     * @param key
     *            the key
     */
    public void setKey(Key key) {
        this.key = key;
    }

    /**
     * Returns the version.
     *
     * @return the version
     */
    public Long getVersion() {
        return version;
    }

    /**
     * Sets the version.
     *
     * @param version
     *            the version
     */
    public void setVersion(Long version) {
        this.version = version;
    }

    public void setItemId(String itemId){
        this.itemId = itemId;
    }

    public String getItemId(){
        return itemId;
    }

    public String getRealm(){
        return realm;
    }

    public void setRealm(String realm){
        this.realm = realm;
    }

    public String getRegion(){
        return region;
    }

    public void setRegion(String region){
        this.region = region;
    }

    public void setDate(Date date){
        this.date = date;
    }

    public Date getDate(){
        return date;
    }

    public ArrayList<Auction> getAuctionData(){
        return auctionData;
    }

    public void setAuctionData(ArrayList<Auction> auctionData){
        this.auctionData = auctionData;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((key == null) ? 0 : key.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        AuctionList other = (AuctionList) obj;
        if (key == null) {
            if (other.key != null) {
                return false;
            }
        } else if (!key.equals(other.key)) {
            return false;
        }
        return true;
    }
}
